import time
import unittest
from HTMLTestRunner import HTMLTestRunner


try:
    test_dir = './test_mall'
    discover = unittest.defaultTestLoader.discover(test_dir, pattern="test*.py")
except Exception as e:
    print(e)
if __name__ == '__main__':
    report_dir = './test_report'
    now = time.strftime('%Y-%m-%d %H %M %S')
    report_name = report_dir + '/' + now + 're.html'

    with open(report_name, 'wb')as f:
        runner = HTMLTestRunner(stream=f, title="测试", description='Test')
        runner.run(discover)
    f.close()
